(function(){
	var AjaxCrud = QualityCheck.AjaxCRUD;
	var serverUrl = QualityCheck.GPUD.ServiceConfig;
	var currentPage = 1;
	var pageSize = 10;
	var totalSize;
	var now = 0;
	var dataCache = [];
	$(function(){
		var usercode = $("#user-name",parent.parent.document).attr("code");
		var userkey = $("#user-name",parent.parent.document).attr("key");
		var usertype = $("#user-name",parent.parent.document).attr("usertype");
		keyCheck(usercode,usertype,userkey,function(){
			initSmPages();
			window.onresize = function () {
				initSmPages();
			};
			pagebtns();
			initGradeClass();
		});
	});
	function initGradeClass(){
		var cont = "";
		var classcont = $(".classes-choice",parent.document);
		if(classcont.length > 0){
			classcont.each(function(i){
				if(i == 0){
					cont += "<option value='"+$(this).attr("classcode")+"' type='"+$(this).attr("type")+"' selected='selected'>"+$(this).text()+"</option>";
				}else{
					cont += "<option value='"+$(this).attr("classcode")+"' type='"+$(this).attr("type")+"'>"+$(this).text()+"</option>";
				}
			});
		}else{
			cont += "<option value='' type=''>班级</option>";
		}
		$("#exam-classcode").html(cont);
		
		initExam(1,pageSize);
		
		$("#exam-classcode").unbind("change");
		$("#exam-classcode").change(function(){
			initExam(1,pageSize);
		});
	}
	function initExam(currentpage,pagesize){
		var userKey = $("#user-name",parent.parent.document).attr("key");
		var schoolcode = $("#user-name",parent.parent.document).attr("schoolcode");
		var starttime = strToDate($("#start-time").val() + ":00")/1000;
		var endtime = strToDate($("#end-time").val() + ":00")/1000;
		var classcode = $("#exam-classcode option:selected").val();
		var obj = {
				classcode:classcode,
				schoolcode:schoolcode,
				currentpage:currentpage,
				pagesize:pagesize,
		};
		if($("#start-time").val() != "" && $("#end-time").val() != ""){
			obj.stime = starttime;
			obj.etime = endtime;
			$("#judge-time").hide();
		}else if($("#start-time").val() == "" && $("#end-time").val() == ""){
			$("#judge-time").hide();
		}else{
			$("#judge-time").text("请把时间填充完整");
			$("#judge-time").show();
			return false;
		}
		var data = {
				cmd:"getTeacherTestList",
				model:"bigexam",
				userKey:userKey,
				data:obj,
				remark:"",
				
		};
		processBegin("正在运行中···");
		AjaxCrud.get(serverUrl.ServerLoginUrl,data,function(res){
			var content = "";
			var pagecontent = "<div class=\"pages-btn-next\">&gt;&gt;</div>";
			if(res.result == 1 && res.data != undefined && res.data != ""){
				processEnd("查询成功");
				var data = res.data.data;
				if(data.length > 0){
					var total = res.data.total;
					totalSize = Math.ceil(total/pagesize);
					if(totalSize <= 5 && totalSize >0){
						for(var i = totalSize-1 ; i >= 0; i--){
							if(i == currentpage-1){
								pagecontent += "<div class=\"pages-btn page-btn-select\">"+(i + 1)+"</div>"; 
							}else{
								pagecontent += "<div class=\"pages-btn\">"+(i + 1)+"</div>"; 
							}
						}
					}else if(totalSize == 0){
						pagecontent += "<div class=\"pages-btn\">1</div>";
					}else if(totalSize > 5){
						var lastp = (now*5)+5;
						if(lastp > totalSize){
							lastp = totalSize;
						}
						for(var i = lastp-1 ; i >= (now*5); i--){
							if(i == currentpage-1){
								pagecontent += "<div class=\"pages-btn page-btn-select\">"+(i + 1)+"</div>"; 
							}else{
								pagecontent += "<div class=\"pages-btn\">"+(i + 1)+"</div>"; 
							}
						}
					}
					pagecontent += "<div class=\"pages-btn-last\">&lt;&lt;</div>";
					$("#student-page").empty();
					$("#student-page").append(pagecontent);
					
					$(".pages-btn").unbind("click");
					$(".pages-btn").click(function(){
						$(".pages-btn").removeClass("page-btn-select");
						$(this).addClass("page-btn-select");
						currentPage = parseInt($(this).text());
						initExam(currentPage,pageSize);
					});
					
					$(".pages-btn-last").unbind("click");
					$(".pages-btn-last").click(function(){
						if(totalSize <= 5 && totalSize >0){
							return false;
						}else if(totalSize == 0){
							return false;
						}else if(totalSize > 5){
							if(now > 0){
								now --;
								initExam((now*5+1),pageSize);
							}else{
								return false;
							}
						}
					});
					
					$(".pages-btn-next").unbind("click");
					$(".pages-btn-next").click(function(){
						if(totalSize <= 5 && totalSize >0){
							return false;
						}else if(totalSize == 0){
							return false;
						}else if(totalSize > 5){
							if(totalSize%5 == 0){
								if((now+1) < totalSize/5){
									now ++;
									initExam((now*5+1),pageSize);
								}else{
									return false;
								}
							}else{
								if((now+1) <= (totalSize-totalSize%5)/5){
									now ++;
									initExam((now*5+1),pageSize);
								}else{
									return false;
								}
							}
						}
					});
					if(data.length > 0){
						dataCache = [];
						for(var i = 0; i < data.length; i++){
							for(var key in data[i]){
								if(data[i][key] == null || data[i][key] == "null" || data[i][key] == undefined){
									data[i][key] = "";
								}
							}
							content += "<div class=\"table-trs\">" +
								"<div class=\"tables-left\" style='margin-left:15px;width:320px;'>" +
									"<div class=\"table-name\" style='width:320px;' subjectcode='"+data[i].subjectcode+"' examcode=\""+data[i].examcode+"\" examname=\""+data[i].examname+"\" classcode=\""+data[i].classcode+"\" title='"+data[i].examname+"'><a href='javascript:void(0)' class='into-exam-detail'>"+substr(data[i].examname,6) + "</a></div>" +
									"<div class=\"table-code\" style='width:320px;' title='"+data[i].describes+"'>"+substr(data[i].describes,18)+"</div>" +
								"</div>" +
								"<div class=\"tables-right\">" +
									"<div class=\"table-address\">创建于:"+getFormatDateByLong(parseInt(data[i].createtime)*1000,"yyyy-MM-dd hh:mm")+"</div>" +
									"<div class=\"table-oprate\">" +
										"<div class=\"table-score\" examcode=\""+data[i].examcode+"\" examname=\""+data[i].examname+"\" classcode=\""+data[i].classcode+"\" subjectcode=\""+data[i].subjectcode+"\" title=\"成绩\" style='margin-left:35px;'></div>" +
										"<div class=\"table-inputResults\" examcode=\""+data[i].examcode+"\" examname=\""+data[i].examname+"\" classcode=\""+data[i].classcode+"\" subjectcode=\""+data[i].subjectcode+"\" title=\"录入\" style='margin-left:15px;'></div>" +
										"<div class=\"table-edit\" index='"+i+"' id=\""+data[i].id+"\" examcode=\""+data[i].examcode+"\" title=\"编辑\" style='margin-left:15px;'></div>" +
										"<div class=\"table-delete\" examcode=\""+data[i].examcode+"\" title=\"删除\" style='margin-left:15px;'></div>" +
									"</div>" +
								"</div>" +
							"</div>";
							dataCache.push(data[i]);
						}
						$("#exam-data-show").empty();
						$("#exam-data-show").append(content);
						
						$(".table-trs").unbind("hover");
						$(".table-trs").hover(function(){
							$(this).find(".table-oprate").show();
						},function(){
							$(".table-oprate").hide();
						});
						
						$(".table-name").unbind("click");
						$(".table-name").click(function(){
							var examcode = $(this).attr("examcode");
							var examname = $(this).attr("examname");
							var classcode = $(this).attr("classcode");
							var subjectcode = $(this).attr("subjectcode");
							$("#score-form-show").contents().find(".table-title").text(examname + "成绩单");
							$("#score-form-show").show();
							$("#right-tables").hide();
							$(".title-search").hide();
							getScoreResults(examcode,classcode);
							
							$("#score-form-show").contents().find("#back-to-table").unbind("click");
							$("#score-form-show").contents().find("#back-to-table").click(function(){
								$("#right-tables").show();
								$("#score-form-show").hide();
								$(".title-search").show();
							});
						});
						//成绩
						$(".table-score").unbind("click");
						$(".table-score").click(function(){
							var examcode = $(this).attr("examcode");
							var examname = $(this).attr("examname");
							var classcode = $(this).attr("classcode");
							var subjectcode = $(this).attr("subjectcode");
							$("#score-form-show").contents().find(".table-title").text(examname + "成绩单");
							$("#score-form-show").show();
							$("#right-tables").hide();
							$(".title-search").hide();
							getScoreResults(examcode,classcode);
							
							$("#score-form-show").contents().find("#back-to-table").unbind("click");
							$("#score-form-show").contents().find("#back-to-table").click(function(){
								$("#right-tables").show();
								$("#score-form-show").hide();
								$(".title-search").show();
							});
						});
						//成绩录入
						$(".table-inputResults").unbind("click");
						$(".table-inputResults").click(function(){
							var examcode = $(this).attr("examcode");
							var examname = $(this).attr("examname");
							var classcode = $(this).attr("classcode");
							$("#inputResults-form-show").contents().find(".table-title").text(examname + "成绩录入");
							$("#inputResults-form-show").show();
							$("#right-tables").hide();
							$(".title-search").hide();
							getInputResults(examcode,classcode);
							
							$("#inputResults-form-show").contents().find("#back-to-table").unbind("click");
							$("#inputResults-form-show").contents().find("#back-to-table").click(function(){
								$("#right-tables").show();
								$("#inputResults-form-show").hide();
								$(".title-search").show();
							});
						});
						
						$(".table-edit").unbind("click");
						$(".table-edit").click(function(){
							var flag = "edit";
							var index = $(this).attr("index");
							var id = $(this).attr("id");
							var examcode = $(this).attr("examcode");
							showData(dataCache[index],flag);
							
							$("#exam-form-show").contents().find("#back-to-table").unbind("click");
							$("#exam-form-show").contents().find("#back-to-table").click(function(){
								$("#exam-form-show").hide();
								$("#right-tables").show();
							});
							
							$("#exam-form-show").contents().find("#save-btns").unbind("click");
							$("#exam-form-show").contents().find("#save-btns").click(function(){
								if(checkSave()){
									if(check2()){
										updataExam(id,examcode);
									}
								}
							});
							check1("exam-examname",isNull,"null","exam-form-show");
							check1("exam-describes",isNull,"null","exam-form-show");
							check1("exam-stime",isNull,"null","exam-form-show");
							check1("exam-etime",isNull,"null","exam-form-show");
							
						});
						
						$(".table-delete").unbind("click");
						$(".table-delete").click(function(){
							var examcode = $(this).attr("examcode");
							deleteBox("确定要删除吗？",function(){
								deleteExam(examcode);
							});
						});
					}else{
						content += "<div class=\"table-trs\">" +
										"<div class=\"no-data-show\">没有查到相关结果！</div>" +
									"</div>";
						$("#exam-data-show").empty();
						$("#exam-data-show").append(content);
					}
				}else{
					content += "<div class=\"table-trs\">" +
									"<div class=\"no-data-show\">没有查到相关结果！</div>" +
								"</div>";
					$("#exam-data-show").empty();
					$("#exam-data-show").append(content);
				};
			}else{
				processError("查询失败");
				content += "<div class=\"table-trs\">" +
								"<div class=\"no-data-show\">没有查到相关结果！</div>" +
							"</div>";
				$("#exam-data-show").empty();
				$("#exam-data-show").append(content);
			}
			initClassEdit();
		},null,null);	
	}
	
	function initClassEdit(){
		var cont = "<option value='' type=''>班级</option>";
		var classcont = $(".classes-choice",parent.document);
		if(classcont.length > 0){
			classcont.each(function(i){
				if(i == 0){
					cont += "<option value='"+$(this).attr("classcode")+"' type='"+$(this).attr("type")+"' selected='selected'>"+$(this).text()+"</option>";
				}else{
					cont += "<option value='"+$(this).attr("classcode")+"' type='"+$(this).attr("type")+"'>"+$(this).text()+"</option>";
				}
			});
		}
		$("#exam-form-show").contents().find("#exam-classcode").html(cont);
		
		var type = $("#exam-form-show").contents().find("#exam-classcode option:selected").attr("type");
		getAllCourseSubject(type);
		
		$("#exam-form-show").contents().find("#exam-classcode").unbind("change");
		$("#exam-form-show").contents().find("#exam-classcode").change(function(){
			var type = $("#exam-form-show").contents().find("#exam-classcode option:selected").attr("type");
			getAllCourseSubject(type);
		});
	}
	
	function getAllCourseSubject(type){
		var userKey = $("#user-name",parent.parent.document).attr("key");	
		var schoolcode = $("#user-name",parent.parent.document).attr("schoolcode");
		var data = {
				cmd:"getAllCourseSubject",
				model:"course",
				userKey:userKey,
				data:{
					type:type,
					schoolcode:schoolcode,
				},
				remark:"",
				
		};
		AjaxCrud.get(serverUrl.ServerLoginUrl,data,function(res){
			if(res.result == 1){
				var cont = "";
				var data = res.data;
				if(data.length > 0){
					for(var i = 0; i < data.length; i++){
						cont += "<option value='"+data[i].subjectcode+"' coursename='"+data[i].coursecontent+"'>"+data[i].coursecontent+"</option>";
					};
				}else{
					cont += "<option value='' coursename=''>科目</option>";
				}
				$("#exam-form-show").contents().find("#exam-coursename").html(cont);
			};
		},null,null);
	}
	
	function showData(data,type){
		$("#exam-form-show").show();
		$("#right-tables").hide();
		if(type == "detail"){
			$("#exam-form-show").contents().find("#save-btns-content").hide();
		}else if(type == "edit"){
			$("#exam-form-show").contents().find("#save-btns-content").show();
		}
		$("#exam-form-show").contents().find("#exam-examname").val(data.examname);
		$("#exam-form-show").contents().find("#exam-describes").val(data.describes);
		$("#exam-form-show").contents().find("#exam-createtime").val(getFormatDateByLong(parseInt(data.createtime)*1000,"yyyy-MM-dd hh:mm"));
		$("#exam-form-show").contents().find("#exam-stime").val(getFormatDateByLong(parseInt(data.stime)*1000,"yyyy-MM-dd hh:mm"));
		$("#exam-form-show").contents().find("#exam-etime").val(getFormatDateByLong(parseInt(data.etime)*1000,"yyyy-MM-dd hh:mm"));
		$("#exam-form-show").contents().find("#exam-coursename option").each(function(i){
			if(data.subjectcode == this.value){
				$(this).attr("selected",true);
				return false;
			}
		});
		$("#exam-form-show").contents().find("#exam-classcode option").each(function(i){
			if(this.value == data.classcode){
				$(this).attr("selected",true);
				return false;
			}
		});
		if(type == "detail"){
			$("#exam-form-show").contents().find("input").attr("disabled","disabled");
			$("#exam-form-show").contents().find("input").css("background-color","#E5E5E5");
			$("#exam-form-show").contents().find("select").attr("disabled","disabled");
			$("#exam-form-show").contents().find("select").css("background-color","#E5E5E5");
			$("#exam-form-show").contents().find("textarea").attr("disabled","disabled");
			$("#exam-form-show").contents().find("textarea").css("background-color","#E5E5E5");
		}else if(type == "edit"){
			$("#exam-form-show").contents().find(".input").removeAttr("disabled");
			$("#exam-form-show").contents().find(".input").css("background-color","#fff");
			$("#exam-form-show").contents().find("select").removeAttr("disabled");
			$("#exam-form-show").contents().find("select").css("background-color","#fff");
			$("#exam-form-show").contents().find("textarea").removeAttr("disabled");
			$("#exam-form-show").contents().find("textarea").css("background-color","#fff");
		};
	}
	
	//录入成绩
	function getInputResults(examcode,classcode){
		processBegin("正在运行中···");
		var userKey = $("#user-name",parent.parent.document).attr("key");
		var schoolcode = $("#user-name",parent.parent.document).attr("schoolcode");
		var obj = {
				examcode:examcode,
				classcode:classcode,
				schoolcode:schoolcode,
		};
		var data = {
				cmd:"queryTeacherStudent",
				model:"bigexam",
				userKey:userKey,
				data:obj,
				remark:"",
				
		};
		AjaxCrud.get(serverUrl.ServerLoginUrl,data,function(res){
			var content = "";
			if(res.result == 1 && res.data != undefined && res.data != ""){
				processEnd("查询成功");
				var data = res.data.data;
				if(data.length > 0){
					content += "<table class='inputresults-table'>";
					for(var i = 0; i < data.length; i++){
						content += "<tr><td>"+data[i].studentname+"</td><td>"+data[i].studentcode+"</td><td>"+data[i].grades+"年级"+data[i].classes+"班</td><td>分数：<input type='text' value='"+data[i].result+"' name='input-result'></td></tr>";
					}
					content += "</table><div class='add-stu-bottom' style='margin-top:35px;'><div class='save-btns' id='save-btns'>保&nbsp;存</div></div>";
					$("#inputResults-form-show").contents().find("#result-data-show").empty();
					$("#inputResults-form-show").contents().find("#result-data-show").append(content);
					
					var cdsH =$("#inputResults-form-show").height() - $("#inputResults-form-show").contents().find(".content-title").height() - 40;
					$("#inputResults-form-show").contents().find(".content-data-show").height(cdsH);
					
					$("#inputResults-form-show").contents().find("#save-btns").unbind("click");
					$("#inputResults-form-show").contents().find("#save-btns").click(function(){
						saveInputResults(examcode,classcode);
					});
					
				}else{
					content += 	"<div class=\"table-trs\">" +
									"<div class=\"no-data-show\">没有查到相关结果！</div>" +
								"</div>";
					$("#inputResults-form-show").contents().find("#result-data-show").empty();
					$("#inputResults-form-show").contents().find("#result-data-show").append(content);
				}
			}else{
				processError("查询失败");
				content += "<div class=\"table-trs\">" +
								"<div class=\"no-data-show\">没有查到相关结果！</div>" +
							"</div>";
				$("#inputResults-form-show").contents().find("#result-data-show").empty();
				$("#inputResults-form-show").contents().find("#result-data-show").append(content);
			}
		},null,null);	
	}
	
	function saveInputResults(examcode,classcode){
		var userKey = $("#user-name",parent.parent.document).attr("key");
		var schoolcode = $("#user-name",parent.parent.document).attr("schoolcode");
		var list = [];
		$("#inputResults-form-show").contents().find(".inputresults-table tr").each(function(){
			var param = {};
			param.schoolcode = schoolcode;
			param.classcode = classcode;
			param.examcode = examcode;
			$(this).children().each(function(i){
				if(i == 0){
					param.studentname = $(this).text();
					return true;
				}else if(i == 1){
					param.studentcode = $(this).text();
					return true;
				}else if(i == 2){
					param.classesname = $(this).text();
					return true;
				}else if(i == 3){
					param.result = $(this).find("input[name='input-result']").val();
					return true;
				}
			});
			list.push(param);
		});
		var data = {
				cmd:"teacherEntryResult",
				model:"bigexam",
				userKey:userKey,
				data:JSON.stringify(list),
				remark:"",						
		};
		processBegin("正在保存中···");
		AjaxCrud.add(serverUrl.ServerLoginUrl,data,function(res){
			if(res.result == 1){
				processEnd("保存成功");
				$("#inputResults-form-show").hide();
				$("#right-tables").show();
				currentPage = 1;
				initExam(currentPage,pageSize);
			}else{
				processError("保存失败");
			}
		},null,null);
	}
	
	//点击科目查看该科目的成绩单信息
	function getScoreResults(examcode,classcode){
		processBegin("正在运行中···");
		var userKey = $("#user-name",parent.parent.document).attr("key");
		var schoolcode = $("#user-name",parent.parent.document).attr("schoolcode");
		var data = {
				cmd:"getTeacherResultList",
				model:"bigexam",
				userKey:userKey,
				data:{
					examcode:examcode,
					schoolcode:schoolcode,
					classcode:classcode,
				},
				remark:"",						
		};
		AjaxCrud.get(serverUrl.ServerLoginUrl,data,function(res){
			var content = "";
			if(res.result == 1 && res.data != undefined && res.data != ""){
				processEnd("查询成功");
				var data = res.data.data;
				if(data.length > 0){
					for(var i = 0; i < data.length; i++){
						for(var key in data[i]){
							if(data[i][key] == null || data[i][key] == "null" || data[i][key] == undefined){
								data[i][key] = "";
							}
						}
						content += "<div class=\"table-trs\">" +
							"<div class=\"tables-left\" style='margin-left:15px;width:120px;'>" +
								"<div class=\"table-name\" style='width:120px;' title='"+data[i].studentname+"'>"+substr(data[i].studentname,5) + "</div>" +
								"<div class=\"table-code\" style='width:120px;'>"+data[i].studentcode+"</div>" +
							"</div>" +
							"<div class=\"tables-middle\" style='margin-left:25%;'>" +
								"<div class=\"table-class\" style='width:200px;'>分数： "+data[i].result+"</div>" +
								"<div class=\"table-code\" style='width:200px;'>"+data[i].grades+"年级"+data[i].classes+"班</div>" +
							"</div>" +
							"<div class=\"tables-right\">" +
								"<div class=\"table-address\">排名：第   "+data[i].classranking+" 名</div>" +
								"<div class=\"table-address\"></div>" +
							"</div>" +
						"</div>";
					}
					$("#score-form-show").contents().find("#result-data-show").empty();
					$("#score-form-show").contents().find("#result-data-show").append(content);
					
					var cdsH =$("#score-form-show").height() - $("#score-form-show").contents().find(".content-title").height() - 40;
					$("#score-form-show").contents().find(".content-data-show").height(cdsH);
					
					//导出成绩单
					$("#score-form-show").contents().find("#leadingout-btn").unbind("click");
					$("#score-form-show").contents().find("#leadingout-btn").click(function(){
						exportScore(examcode,classcode);
					
					});
				}else{
					content += "<div class=\"table-trs\">" +
									"<div class=\"no-data-show\">没有查到相关结果！</div>" +
								"</div>";
					$("#score-form-show").contents().find("#result-data-show").empty();
					$("#score-form-show").contents().find("#result-data-show").append(content);
				}
			}else{
				processError("查询失败");
				content += "<div class=\"table-trs\">" +
								"<div class=\"no-data-show\">没有查到相关结果！</div>" +
							"</div>";
				$("#score-form-show").contents().find("#result-data-show").empty();
				$("#score-form-show").contents().find("#result-data-show").append(content);
			}
		},null,null);
	}
	//编辑考试
	function updataExam(id,examcode){
		var userKey = $("#user-name",parent.parent.document).attr("key");
		var usercode = $("#user-name",parent.parent.document).attr("code");
		var usertype = $("#user-name",parent.parent.document).attr("usertype");
		var schoolcode = $("#user-name",parent.parent.document).attr("schoolcode");
		var param = {};
		param.usercode = usercode;
		param.usertype = usertype;
		param.schoolcode = schoolcode;
		param.id = id;
		param.examcode = examcode;
		param.examname = encodeURI($("#exam-form-show").contents().find("#exam-examname").val());
		param.classcode = $("#exam-form-show").contents().find("#exam-classcode option:selected").val();
		param.describes = encodeURI($("#exam-form-show").contents().find("#exam-describes").val());
		param.subjectcode = $("#exam-form-show").contents().find("#exam-coursename option:selected").val();
		param.stime = strToDate($("#exam-form-show").contents().find("#exam-stime").val() + ":00")/1000;
		param.etime = strToDate($("#exam-form-show").contents().find("#exam-etime").val() + ":00")/1000;
		param.createtime = new Date().getTime()/1000;
		var data = {
				cmd:"updateTeahcerExamInfo",
				model:"bigexam",
				userKey:userKey,
				data:param,
				remark:"",						
		};
		processBegin("正在保存中···");
		AjaxCrud.get(serverUrl.ServerLoginUrl,data,function(res){
			if(res.result == 1){
				processEnd("修改成功");
				$("#exam-form-show").hide();
				$("#right-tables").show();
				currentPage = 1;
				initExam(currentPage,pageSize);
			}else{
				processError("修改失败");
			}
		},null,null);
	}
	//删除考试
	function deleteExam(examcode){
		var userKey = $("#user-name",parent.parent.document).attr("key");
		var schoolcode = $("#user-name",parent.parent.document).attr("schoolcode");
		var data = {
				cmd:"deleteTeacherExamInfo",
				model:"bigexam",
				userKey:userKey,
				data:{
					examcode:examcode,
					schoolcode:schoolcode
				},
				remark:"",						
			};
			processBegin("正在删除中···");
			AjaxCrud.get(serverUrl.ServerLoginUrl,data,function(res){
				if(res.result == 1){
					processEnd("删除成功");
					currentPage = 1;
					initExam(currentPage,pageSize);
				}else{
					processError("删除失败");
				}
			},null,null);
	}
	
	function exportScore(examcode,classcode){
		var schoolcode = $("#user-name",parent.parent.document).attr("schoolcode");
		window.frames["export"].location = serverUrl.ExportUrl + "?t=" + Math.random() + "&cmd=getTeacherResultList" + "&examcode=" + examcode + "&classcode=" + classcode + "&schoolcode=" + schoolcode + "&fileName=" + new Date().getTime();
	}
	
	function check2(){
		var flg = false;
		var checkFails = $("#exam-form-show").contents().find(".check-fail");
		for(var i = 0; i < checkFails.length; i++){
			if(checkFails[i].innerHTML != ""){
				flg = false;
				break;
			}else{
				flg = true;
			}
		}
		return flg;
	}

	function checkSave(){
		var flag = false;
		var parame = ["examname","classcode","coursename","stime","etime","describes"];
		for(key in parame){
			if($("#exam-form-show").contents().find("#exam-" + parame[key]).val() == ""){
				$("#exam-form-show").contents().find("#exam-" + parame[key]).focus();
				$("#exam-form-show").contents().find("#exam-" + parame[key] + "-ex").text("不能为空！");
				return false;
			}else{
				flag = true;
			};
		}
		return flag;
	}
	function substr(str,len){
		if(str != undefined){
			if(str.length > len){
				str = str.substring(0,len-2)+"...";
				return str;
			}else{
				return str;
			}
		}else{
			return "";
		}
	}
	
	
	function pagebtns(){
		$("#exam-search-btn").click(function(){
			now = 0;
			initExam(1,pageSize);
		});	
		$("#inputResults-search-btn").click(function(){
			initExam(1,pageSize);
		});	
		
	}
	function initSmPages(){
		var rcH = $(".body-right",parent.document).height() - $(".right-title").height()-3;
		$(".right-content").height(rcH);
		
		var cdsH = $(".right-content").height() - $(".content-title").height() - 40;
		$(".content-data-show").height(cdsH);
	}
})();